package com.cloud.DrugManagement.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author zhozixiong
 * @date 2023/02/03
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                //指定构建api文档的详细信息
                .apiInfo(getapiInfo())
                .select()
                //指定要生成api接口包的路径
                .apis(RequestHandlerSelectors.basePackage("com.cloud.DrugManagement.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo getapiInfo() {
        return new ApiInfoBuilder()
                //药品管理系统接口文档
                .title("SpringBoot集成Swagger接口总览")
                //详细信息
                .description("接口说明")
                //网站地址
                .termsOfServiceUrl("http://localhost:8080/")
                //版本
                .version("1.0")
                //构建
                .build();
    }
}
